package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/7/29 21:58
 */
public class BorrowOperation implements IOPeration{
    @Override

        public void work(BookList bookList){
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入想要借阅的书名");
            String name = scanner.nextLine();
            int currentSize = bookList.getUsedSize();
            int i = 0;
            //查找这本书
            for (; i < currentSize; i++) {
                Book book = bookList.getBook(i);
                if (book.getName().equals(name)){
                    System.out.println("借阅成功");
                    book.setIsborrowed(true);
                    System.out.println(book);
                    return;
                }
                //没有这本书
            }System.out.println("查无此书");


    }
}
